package com.example.spring6iocxml.demoBean;

import com.example.spring6iocxml.controller.UserController;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @ClassName HelloTest
 * @Date 2024/5/20 14:46
 * @Description TODO
 * @User lihuajie
 * @Version 1.0.0
 **/
public class HelloTest {

    private Logger logger = LoggerFactory.getLogger(HelloTest.class);

    @Test
    public void testHello(){
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("springs.xml");
        Hello hello =(Hello) applicationContext.getBean("Hello");
        hello.sayHello();
        logger.info("执行成功");
    }

    @Test
    public void test1(){
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("springs.xml");
        Hello hello =(Hello) applicationContext.getBean(Hello.class);
        hello.sayHello();
        logger.info("test1-执行成功");
    }

    @Test
    public void test2(){
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("springs.xml");
        Hello hello =(Hello) applicationContext.getBean("Hello",Hello.class);
        hello.sayHello();
        logger.info("test2-执行成功");
    }

    @Test
    public void test3(){
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("springs.xml");
        UserController userController = (UserController) applicationContext.getBean("userController");
        userController.save();
    }

}
